<?php 
$file = $_GET['filename'];
$sizeset = false;
list($width, $height) = getimagesize($file);

if($_GET['max']) { 
	$pct = $_GET['max'] / $width;
	$modwidth = $_GET['max'];
	//Ajuste la taille du thumbnail proportionnellement à sa taille de depart
	$modheight = round($height*$pct);
	$sizeset = true;
}

//Enregistre le type de l'image
header('Content-type: image/jpeg');

//Redimensionner l'image
$tn = imagecreatetruecolor($modwidth, $modheight);
$image = imagecreatefromjpeg($file);
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height);

imagejpeg($tn, null, 100);
?>